<!-- container box 嵌套 box -->
<template>
  <div class="nesting-box">
    <el-row>
      <el-col :span="24">
        <div style="text-align:right;">
          <el-divider content-position="left">操作</el-divider>
          <el-tooltip v-if="nestingBoxShow.showAppend" class="item" effect="dark" content="该容器组件内追加栅格"
            placement="bottom-start">
            <el-button @click.stop="appendContainerCol" type="primary" plain size="mini">
              添加
            </el-button>
          </el-tooltip>
          <el-tooltip v-if="pullComponent" class="item" effect="dark" content="抽离出多余的容器组件，只渲染展示组件！"
            placement="bottom-start">
            <el-button @click.stop="pullContainerPushComponent" type="success" plain size="mini">
              抽离
            </el-button>
          </el-tooltip>
          <el-button v-if="nestingBoxShow.showClean" @click.stop="clearContainerBoxChild" type="warning" size="mini">
            清空
          </el-button>
          <el-button v-if="nestingBoxShow.showBack" @click.stop="chooseMind" size="mini">返回 <i
              class="el-icon-right"></i>
          </el-button>
        </div>
        <el-divider content-position="left">设置</el-divider>
        <el-form @submit.native.prevent>
          <el-form-item label="插入位置" :label-width="formLabelWidth" style="margin-bottom: 0px;">
            <el-radio-group v-model="containerCol.position">
              <el-radio size="mini" :label="-1">容器组件内顶部</el-radio>
              <el-radio size="mini" :label="-2">容器组件内底部</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="选择栅格类型" :label-width="formLabelWidth" style="margin-bottom: 0px;">
            <el-radio-group v-model="containerCol.girdtype" class="radio-disblock">
              <el-radio size="mini" label="col-sm">768px及以下（手机竖屏）换行</el-radio>
              <el-radio size="mini" label="col-md">992px及以下（手机横屏）换行</el-radio>
              <el-radio size="mini" label="col-lg">1200px及以下（ipad）换行</el-radio>
              <el-radio size="mini" label="col-xs">不换行</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="列数" :label-width="formLabelWidth" style="margin-bottom: 0px;">
            <el-input size="mini" type="number" style="width:80px;" v-model="containerCol.col" min="1" :max="maxcol"
              placeholder=""></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  props: {
    appendContainerCol: {
      type: Function
    },
    clearContainerBoxChild: {
      type: Function
    },
    chooseMind: {
      type: Function
    },
    nestingBoxShow: {
      type: Object
    },
    maxcol: {
      type: Number,
      default: 12
    },
    pullComponent: {
      type: Boolean,
      default: false
    },
    pullContainerPushComponent: {
      type: Function
    }
  },
  computed: {
    ...mapState([
      'design'
    ])
  },
  data () {
    return {
      formLabelWidth: '120px',
      // 默认数据
      containerCol: {
        position: -2,
        girdtype: 'col-xs',
        col: 1
      }
    }
  },
  methods: {
    init () {
      this.containerCol = {
        position: -2,
        girdtype: 'col-xs',
        col: 1
      }
    },
    getContainerCol () {
      if (this.containerCol.col > this.maxcol || this.containerCol.col < 1) {
        this.$message.error('列数最少不能低于 1 列，最多不能高于 ' + this.maxcol + ' 列！')
        return
      }
      return this.containerCol
    }
  }
}

</script>

<style scoped lang="scss">
.radio-disblock {
  padding-top: 5px;
  padding-bottom: 10px;

  /deep/ .el-radio {
    line-height: 30px;
    min-width: 40%;
  }
}
</style>
